import {
	createApp
} from 'vue';
import App from './App.vue';
import router from './router'; // 导入router
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import './utils/rem.js'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import {
	TinyColor
} from '@ctrl/tinycolor';

zhCn.el.pagination.total = '共' + `{total}` + '条数据'


// 动态改变主题色
function changeThemeColor(color) {
	const colorObj = new TinyColor(color);
	document.documentElement.style.setProperty('--el-color-primary', colorObj.toHexString());
}


// 创建并挂载应用的函数
async function bootstrap() {
	

	const app = createApp(App);

	for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
		app.component(key, component)
	}

	app.use(ElementPlus, {
		locale: zhCn
	});
	app.use(router);
	
	// 动态改变主题色
	changeThemeColor('#4F46E5');
	app.mount('#app');
}

// 启动应用
bootstrap();